import service from "@/service";
import Qs from "qs";
import { getLoginData } from "@/tools";
let app = getLoginData();
//根据用户登录id,租户id查询标段列表数据
export function getBlockList(parameter) {
  let { permissionCode } = app;
  let { userId, tenantCode } = parameter;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-org/getSGInfoByTenatCode?userId=${userId}&tenantCode=${tenantCode}`,
    method: "POST",
    data: {
      systemCode: permissionCode,
    },
  });
}

//字典数据列表
export function queryConfigDictData(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/config-dict-data/list`,
    method: "POST",
    data: parameter,
  });
}

//获取附件地址
export function getFilePath(id) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/configFile/getFilePath?id=` + id,
    method: "GET",
  });
}

//物料基础列表数据查询-列表
export function queryMaterialBaseList(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBaseInfo/materialBaseInfoList?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//查询供应商列表
export function querySupplierList(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBaseInfo/supplierList`,
    method: "POST",
    data,
  });
}

//物料基础列表-新增
export function addSupplierList(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBaseInfo/add`,
    method: "POST",
    data,
  });
}

//物料基础列表-删除
export function materialOutStoragedelete(parameter) {
  let { id } = parameter;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBaseInfo/delete?id=${id}`,
    method: "GET",
  });
}

//物料基础列表-详情
export function queryMaterialDetails(parameter) {
  let { id } = parameter;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBaseInfo/detail?id=${id}`,
    method: "GET",
  });
}

//物料基础列表-编辑
export function editSupplierList(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBaseInfo/edit`,
    method: "POST",
    data,
  });
}

//查询物料入库列表
export function queryMaterialList(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/getListData?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//查询物料入库列表页总数据
export function queryMaterialTotalData(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/totalData`,
    method: "POST",
    data,
  });
}

//查询物料入库有日期的数据
export function queryMaterialInHasStorageDate(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/queryDate`,
    method: "GET",
    params: parameter,
  });
}

//物料入库-模板下载
export function downloadMaterialInTemplate(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/downloadTemplate`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//物料入库-导出
export function exportDataMaterialInbaseInfo(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/exportData`,
    method: "POST",
    apiType: "file",
    responseType: "arraybuffer",
    data,
  });
}

//物料入库-导入
export function importMaterialInExcel(formdata) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/importExcel`,
    method: "POST",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: formdata,
  });
}

//物料入库-详情
export function getMaterialInDetail(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/getDetail?id=${id}`,
    method: "POST",
  });
}

//物料入库-编辑
export function editMaterialIn(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/editData?id=${id}`,
    method: "POST",
    data,
  });
}

//查询物料出库列表
export function queryMaterialOutList(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/getListData?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//查询物料入库列表页总数据
export function queryMaterialOutTotalData(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/totalData`,
    method: "POST",
    data,
  });
}

//查询物料出库有日期的数据
export function queryMaterialOutHasStorageDate(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/queryDate`,
    method: "GET",
    params: parameter,
  });
}

//物料出库-导出
export function exportDataMaterialOutbaseInfo(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/exportData`,
    method: "POST",
    apiType: "file",
    responseType: "arraybuffer",
    data,
  });
}

//物料出库-模板下载
export function downloadMaterialOutTemplate(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/downloadTemplate`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//物料出库-导入
export function importMaterialOutExcel(formdata) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/importExcel`,
    method: "POST",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: formdata,
  });
}

//物料出库-详情
export function getMaterialOutDetail(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/getDetail?id=${id}`,
    method: "POST",
  });
}

//物料出库-编辑
export function editMaterialOut(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/editData?id=${id}`,
    method: "POST",
    data,
  });
}

//查询物料归还列表
export function materialBackInfoList(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBackInfo/materialBackInfoList?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//查询物料归还列表页总数据
export function materialBackInfoMoney(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBackInfo/materialBackInfoMoney`,
    method: "POST",
    data,
  });
}

//查询物料归还有日期的数据
export function queryMaterialBackInfoDate(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBackInfo/queryDate`,
    method: "POST",
    data,
  });
}

//物料归还-导出
export function downloadMaterialBackInfo(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBackInfo/downloadMaterialBackInfo`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//物料归还-模板下载
export function downloadMaterialBackTemplate(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBackInfo/downloadTemplate`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//物料归还-导入
export function importMaterialBackExcel(formdata) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBackInfo/importExcel`,
    method: "POST",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: formdata,
  });
}

//物料归还-详情
export function getMaterialBackInfoDetail(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialBackInfo/detail?id=${id}`,
    method: "GET",
  });
}

//查询销售退货列表
export function materialSalereturnInfoList(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialSalereturnInfo/materialSalereturnInfoList?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//查询销售退货有日期的数据
export function materialSalereturnInfo(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialSalereturnInfo/queryDate`,
    method: "POST",
    data,
  });
}

//查询销售退货列表页总数据
export function materialSalereturnInfoMoney(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialSalereturnInfo/materialSalereturnInfoMoney`,
    method: "POST",
    data,
  });
}

//物料入库-附件上传
export function uploadFileByType(data, form) {
  return service({
    method: "POST",
    baseUrl: "gateWaybaseUrl",
    url: `/beam/configFile/uploadFileByType?form=${form}`,
    data,
  });
}

//销售退货-导出
export function downloadMaterialSalereturnInfo(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialSalereturnInfo/downloadMaterialSalereturnInfo`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//销售退货-模板下载
export function downloadMaterialSalereturnTemplate(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialSalereturnInfo/downloadTemplate`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//销售退货-导入
export function importMaterialSalereturnExcel(formdata) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialSalereturnInfo/importExcel`,
    method: "POST",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: formdata,
  });
}

//销售退货-详情
export function getMaterialSalereturnDetail(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialSalereturnInfo/detail?id=${id}`,
    method: "GET",
  });
}

//查询采购退货列表
export function materialPruchasereturnInfoList(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialPruchasereturnInfo/getListData?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//物料入库-新增
export function addMaterialInbaseInfo(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    method: "POST",
    url: `/beam/materialInbaseInfo/addData`,
    data,
  });
}
//查询采购退货有日期的数据
export function materialPruchasereturnDate(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialPruchasereturnInfo/queryDate`,
    method: "POST",
    data,
  });
}
// 查询采购退货列表页总数据
export function materialPruchasereturnInfo(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialPruchasereturnInfo/totalData`,
    method: "POST",
    data,
  });
}

//采购退货-模板下载
export function downloadPruchasereturnTemplate(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialPruchasereturnInfo/downloadTemplate`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//采购退货-导出
export function exportPruchasereturnData(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialPruchasereturnInfo/exportData`,
    method: "POST",
    apiType: "file",
    responseType: "arraybuffer",
    data,
  });
}

//采购退货-导入
export function importPruchasereturnExcel(formdata) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialPruchasereturnInfo/importExcel`,
    method: "POST",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: formdata,
  });
}

//采购退货-详情
export function getMaterialPruchasereturnDetail(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialPruchasereturnInfo/getDetail?id=${id}`,
    method: "POST",
  });
}

//物料出库基础列表数据查询-列表
export function queryMaterialOutBaseList(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/getAddListData?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//物料出库-新增
export function addMaterialOutbaseInfo(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    method: "POST",
    url: `/beam/materialOutbaseInfo/addData`,
    data,
  });
}

//新增选择物料的列表-物品归还、销售退货
export function queryAddListDataBackAndReturn(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/getAddListDataBackAndReturn?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//物料归还-新增
export function addMaterialBackInfo(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    method: "POST",
    url: `/beam/materialBackInfo/add`,
    data,
  });
}

//销售退货-新增
export function addMaterialSalereturnInfo(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    method: "POST",
    url: `/beam/materialSalereturnInfo/add`,
    data,
  });
}

//新增选择物料的列表-采购退货
export function queryPruchaseAddListData(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialPruchasereturnInfo/getPruchaseAddListData?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//采购退货-新增
export function addMaterialPruchasereturnInfo(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    method: "POST",
    url: `/beam/materialPruchasereturnInfo/addData`,
    data,
  });
}

// 查询入库有数据的日期
export function queryMaterialInStorageDate(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/queryDate?${Qs.stringify(parameter)}`,
    method: "GET",
  });
}

// 查询出库有数据的日期
export function queryMaterialOutStorageDate(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialOutbaseInfo/queryDate?${Qs.stringify(parameter)}`,
    method: "GET",
  });
}

//物料统计列表
export function queryMaterialStatistics(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/materialStatis?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//物料统计导出
export function exportMaterialStatistics(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/downloadMaterialStatis`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//客户销售明细表-列表
export function queryCustomSale(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/customSaleDetail?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//客户销售明细表-导出
export function exportCustomSale(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/downloadCustomSaleDetail`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//客户销售汇总表-列表
export function queryCustomSaleStatis(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/customSaleStatis?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//客户销售汇总表-导出
export function exportCustomSaleStatis(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/downloadCustomSaleStatis`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//供货商供货汇总表-列表
export function queryCustomSupplierStatis(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/supplierStatis?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//供货商供货汇总表-导出
export function exportSupplierStatis(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/downloadSupplierStatis`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//供应商供货明细表-列表
export function queryCustomSupplierList(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/supplierList?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//供应商供货明细表-导出
export function exportSupplierList(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/downloadSupplierList`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//发货汇总表-查询
export function querySummaryStatis(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/shipmentSummaryStatis?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//发货汇总表-导出
export function exportSummaryStatis(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/downloadshipmentSummaryStatis`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//供应商库存汇总-列表
export function querySupplierStockStatis(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/supplierStockStatis?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//供应商库存汇总-导出
export function exportSupplierStockStatis(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/downloadSupplierStockStatis`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
    params: parameter,
  });
}

//供应商发项目- 货品
export function querySupplierProjectStatis(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/supplierProjectStatis?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//供应商发项目- 货品列表明细
export function querySupplierProjectStatisDetail(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/supplierProjectStatisDetail?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//供应商发项目- 导出
export function exportSupplierProjectStatisDetail(parameter) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialStatics/downloadsupplierProjectStatisDetail?${Qs.stringify(
      parameter
    )}`,
    method: "GET",
    apiType: "file",
    responseType: "arraybuffer",
  });
}

//检测报告列表
export function getReportList(data) {
  let { page = 1, pageSize = 10 } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/testReportList?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//删除检测报告
export function deleteReport(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/deleteTestReport?id=${id}`,
    method: "POST",
  });
}

//上传检测报告
export function uploadReport(data) {
  let { inbaseId, formdata } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/addTestReport?inbaseId=${inbaseId}`,
    method: "POST",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data: formdata,
  });
}

// 物料树
export function materialTreeList(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/config-dict-data/treeList`,
    method: "POST",
    data,
  });
}

//仓库列表
export function warehouseList(params) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/warehouseList`,
    method: "GET",
    params,
  });
}

//更新质检报告
export function updateReport(params) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/updateReport`,
    method: "GET",
    params,
  });
}

//更新入库数据
export function updateInBase(params) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/beam/materialInbaseInfo/updateInBase`,
    method: "GET",
    params,
  });
}
